package com.learn.datastructures.queue;

import java.util.Stack;

public class Solution {

    public static void main(String[] args) {
        Solution solution=new Solution();
        solution.push(23);
        solution.push(33);
        solution.push(63);
        solution.push(3);
        solution.push(993);


        System.out.println(solution.pop());
        System.out.println(solution.pop());
        System.out.println(solution.pop());
        System.out.println(solution.pop());
        System.out.println(solution.pop());

    }

    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public synchronized void push(int node) {
        stack1.push(node);
    }

    public synchronized int pop() {
        if(stack2.isEmpty()){
            while(stack1.size()>0){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }
}
